import {onMounted, onUnmounted, toRefs,reactive} from "vue";


const useMousePosition = () => {

    const xAndy = reactive({
        x:0,
        y:0
    })
    const upDateMouse = (e:MouseEvent)=>{
        xAndy.x = e.pageX
        xAndy.y = e.pageY
    }

    onMounted(()=>{
        document.addEventListener('click',upDateMouse)
    })

    onUnmounted(()=>{
        document.removeEventListener('click',upDateMouse)
    })
    return toRefs(xAndy)


}
export default useMousePosition;
